<template>
  <div class="page-scan-mana">
    <el-form :inline="true" :model="dataQueryForm" ref="dataQueryForm">
      <div class="pc-page-header">
        <el-form-item  prop="id">
          <el-input v-model="dataQueryForm.userNo" clearable  class="pc-input3-col5" placeholder="输入用户编号"></el-input>
        </el-form-item>
        <el-form-item  prop="id">
          <el-input v-model="dataQueryForm.contactName" clearable  class="pc-input3-col5" placeholder="输入用户姓名"></el-input>
        </el-form-item>
        <el-form-item  prop="id">
          <el-input v-model="dataQueryForm.contactMobileNo" clearable  class="pc-input3-col5" placeholder="输入手机号码"></el-input>
        </el-form-item>
        <el-form-item  prop="id">
          <el-input v-model="dataQueryForm.companyName" clearable  class="pc-input3-col5" placeholder="输入公司名称"></el-input>
        </el-form-item>
        <el-form-item>
          <el-date-picker class="block"
                          v-model="dataQueryForm.statisticDate"
                          type="daterange"
                          range-separator="-"
                          start-placeholder="最近登录开始日期"
                          end-placeholder="最近登录结束日期"
                          value-format="yyyy-MM-dd HH:mm:ss"
                          @change="getDate">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="">
          <el-button type="primary" @click="queryDataFn">搜索</el-button>
          <el-button type="primary" @click="refresh('dataQueryForm')">刷新</el-button>
          <el-button type="primary" @click="exportData('dataQueryForm')">导出</el-button>
        </el-form-item>
      </div>
    </el-form>
    <egrid border class="page-list"
           :data="tableData"
           :columns="columns"
           :columns-schema="columnsSchema"
           :columns-props="columnsProps">
    </egrid>

    <div class="pc-pagination-panel">
      <pc-pagination ref="pcPagination" :url="pageUrl.queryDataList" :queryData="dataQueryForm"
                     @on-query="queryCallBackFn">
      </pc-pagination>
    </div>
  </div>
</template>

<script type="text/ecmascript-6">
  import PcPagination from 'components/form/pagination';
  import PcButton from 'components/form/button';
  import PcDialog from 'components/dialog';
  import EgridCellView from 'components/wms/comm/EgridCellView.vue';
  export default {
    data () {
      return {
        dataQueryForm: {
          userNo: null,
          contactName: null,
          contactMobileNo: null,
          companyName: null
        },
        tableData: [],
        columns: [
          {
            label: '用户编号',
            prop: 'userNo'
          },
          {
            label: '用户昵称',
            prop: 'wxNickName'
          },
          {
            label: '用户姓名',
            prop: 'contactName'
          },
          {
            label: '手机号码',
            prop: 'contactMobileNo'
          },
          {
            label: '公司',
            prop: 'companyName'
          },
          {
            label: '求购',
            prop: 'demandCount'
          },
          {
            label: '报价',
            prop: 'quoteCount'
          },
          {
            label: '查看的求购',
            prop: 'seeDemandCount'
          },
          {
            label: '最近登录时间',
            prop: 'lastLoginTime'
          }
        ],
        columnsSchema: {
          '公司': {minWidth: 200},
          '最近登录时间': {minWidth: 160}
        },
        // columnsProps 用于定义所有 columns 公共的属性，
        // 这里属性可以参考这里： http://element.eleme.io/#/zh-CN/component/table#table-column-attributes
        columnsProps: {
          height: 40,
          minWidth: 140,
          showOverflowTooltip: true,
          component: EgridCellView
        },
        // columnsHandler 可用于在现有的 columns 进行操作，对 columns 进行增删改，这里新增了操作列
        pageUrl: {
          queryDataList: '/ibs/web/user/queryListWithPage'
        }
      };
    },
    components: {
      PcPagination, PcButton, PcDialog
    },
    created () {
    },

    methods: {
      getDate() {
        if (this.dataQueryForm.statisticDate === null) {
          this.dataQueryForm.startDate = '';
          this.dataQueryForm.endDate = '';
        } else {
          this.dataQueryForm.startDate = this.dataQueryForm.statisticDate[0];
          this.dataQueryForm.endDate = this.dataQueryForm.statisticDate[1];
        }
      },
      // 表头样式
      getHeaderStyle({ row, column, rowIndex, columnIndex }) {
        if (rowIndex === 0) {
          return 'background: #f5f5f5; height: 50px';
        } else {
          return '';
        }
      },
      getRowClass({ row, column, rowIndex, columnIndex }) {
        if (rowIndex === 0) {
          return 'background:rgb(245, 245, 245);';
        } else {
          return '';
        }
      },
      openMessage() {
        this.$notify.info({
          title: '自定义位置',
          message: '右下角弹出的消息',
          position: 'bottom-right'
        });
      },
      queryCallBackFn (res) {
        this.tableData = res.result.list;
      },
      queryDataFn () {
        this.$refs.pcPagination.queryListWithPageFn(true);
      },
      refresh (formName) {
        this.$refs[formName].resetFields();
        this.dataQueryForm.userNo = null;
        this.dataQueryForm.contactName = null;
        this.dataQueryForm.contactMobileNo = null;
        this.dataQueryForm.companyName = null;
        this.dataQueryForm.statisticDate = null;
        this.dataQueryForm.startDate = null;
        this.dataQueryForm.endDate = null;
        this.queryDataFn();
      },
      // 导出库存数据
      exportData() {
        this.exportFile({type: 'POST',
          url: '/ibs/web/user/exportUserList',
          data: this.dataQueryForm,
          loading: true,
          fileNameStart: '用户管理列表'
        });
      }
    }
  };
</script>
<style>
  .page-scan-mana .el-upload-list--picture-card .el-upload-list__item-thumbnail{
    width: 146px;
    height: 146px;
    display: block;
    position:relative;
  }
  .page-scan-mana .el-upload-list--picture-card .el-upload-list__item-thumbnail:before{
    content: "\E614";
    position: absolute;
    top: 18px;
    left: 40px;
    color: #b3b3b3;
    font-size: 60px;
    font-family: "maliiconfont" !important;
  }
  .page-scan-mana .topClassEditInfo .el-upload-list--picture-card .el-upload-list__item .el-icon-close
  {
    display: none;
  }
  .page-scan-mana .topClassEditInfo .el-upload-list--picture-card .el-upload-list__item .el-icon-close-tip
  {
    display: none;
  }
</style>
